package ao.com.bna.beans;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "ItemSuplemento")
public class ItemSuplemento implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "ITEMSUPLEMENTO_ID_GENERATOR", sequenceName = "ITEMSUPLEMENTO_SEQ", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ITEMSUPLEMENTO_ID_GENERATOR")
	@Column(nullable = false, precision = 6)
	private Long id;

	@OneToOne
	@JoinColumn(name = "idNota", referencedColumnName = "id", unique=true)
	private Nota nota = new Nota();

	// associação bi-direccional many-to-one
	@ManyToOne
	@JoinColumn(name = "idSuplemento", referencedColumnName = "id", nullable = false)
	private Suplemento suplemento = new Suplemento();

	public ItemSuplemento() {
		super();
		// TODO Auto-generated constructor stub
	}

	
	
	
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}




	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}




	/**
	 * @return the nota
	 */
	public Nota getNota() {
		return nota;
	}

	/**
	 * @param nota
	 *            the nota to set
	 */
	public void setNota(Nota nota) {
		this.nota = nota;
	}

	/**
	 * @return the suplemento
	 */
	public Suplemento getSuplemento() {
		return suplemento;
	}

	/**
	 * @param suplemento
	 *            the suplemento to set
	 */
	public void setSuplemento(Suplemento suplemento) {
		this.suplemento = suplemento;
	}
	

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ItemSuplemento other = (ItemSuplemento) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	
	
	

}